﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MediaDataModel;
using MediaDataModel.Common.Other;
using System.Xml;


namespace WaterMarkerApp
{
    public partial class AddWaterMarker : BaseMainForm
    {
        #region private properties

        #endregion

        public AddWaterMarker()
        {
            InitializeComponent();
        }


        #region Events
        private void AddWaterMarker_Load(object sender, EventArgs e)
        {
            //Customer oCustomer = new Customer();
            //oCustomer.IsOwner = false;

            ComboBoxBindData();
        }

        private void btnNext_Click(object sender, EventArgs e)
        {

        }


        private void btnNext_MouseMove(object sender, MouseEventArgs e)
        {
            btnNext.BackgroundImage = global:: WaterMarkerApp.Properties.Resources.下一步_1;
        }

        private void btnNext_MouseLeave(object sender, EventArgs e)
        {
            btnNext.BackgroundImage = global:: WaterMarkerApp.Properties.Resources.下一步;
        }

        private void lblNavigation_MouseMove(object sender, MouseEventArgs e)
        {
            Label labelControl = sender as Label;
            if (labelControl != null)
            {
                switch (labelControl.Name)
                {
                    case "lbl光盘发行":
                        lbl光盘发行.Image = global::WaterMarkerApp.Properties.Resources.光盘_发行;
                        break;
                    case "lblWenJianFaBu":
                        lblWenJianFaBu.Image = global::WaterMarkerApp.Properties.Resources.文件_发行;
                        break;
                }
            }
        }

        private void lblNavigation_MouseLeave(object sender, EventArgs e)
        {
            Label labelControl = sender as Label;
            if (labelControl != null)
            {
                switch (labelControl.Name)
                {
                    case "lbl光盘发行":
                        lbl光盘发行.Image = global::WaterMarkerApp.Properties.Resources.光盘发行;
                        break;
                    case "lblWenJianFaBu":
                        lblWenJianFaBu.Image = global::WaterMarkerApp.Properties.Resources.文件发行;
                        break;
                }
            }
        }

        private void lblClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
#endregion

        #region private methods
        /// <summary>
        /// 下拉列表的数据绑定
        /// </summary>
        public void ComboBoxBindData()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(@"XML\SystemConfig.xml");
            //水印频率
            XmlNodeList waterMaikerNodeList = xmlDoc.DocumentElement.SelectNodes("waterMarker/marker");
            foreach (XmlNode waterMarkerNode in waterMaikerNodeList)
                cboWaterMarker.Items.Add(new KeyValue { Key = waterMarkerNode.Attributes["name"].Value, Value = waterMarkerNode.Attributes["value"].Value });
            cboWaterMarker.SelectedIndex = 0;

            //视频码率
            XmlNodeList videoRateNodeList = xmlDoc.DocumentElement.SelectNodes("video/bitRate/publish/rate");
            foreach (XmlNode rateNode in videoRateNodeList)
                cboVideoBitrate.Items.Add(new KeyValue { Key = rateNode.Attributes["name"].Value, Value = rateNode.Attributes["value"].Value });
            cboVideoBitrate.SelectedIndex = 0;

            //视频格式
            XmlNodeList videoExtensionNodeList = xmlDoc.DocumentElement.SelectNodes("video/extensions/extension");
            foreach (XmlNode childNode in videoExtensionNodeList)
                cboVideoFormat.Items.Add(childNode.InnerText);
            cboVideoFormat.SelectedIndex = 0;

            //光盘类型
            XmlNodeList GuangPanTypeNodeList = xmlDoc.DocumentElement.SelectNodes("disc/capacity");
            foreach (XmlNode GuangPanTypeNode in GuangPanTypeNodeList)
                cmbGuangPanType.Items.Add(new KeyValue { Key = GuangPanTypeNode.Attributes["name"].Value, Value = GuangPanTypeNode.Attributes["value"].Value });
            this.cmbGuangPanType.SelectedIndex = 0;

            //发行公司
            using (CCTV6Entities db = new CCTV6Entities())
            {
                var customers = db.Customers.Where(customer => customer.IsOwner.HasValue == false || customer.IsOwner.Value == false);
                if (customers != null && customers.Count() > 0)
                {
                    foreach (var customer in customers)
                        cmbCompany.Items.Add(customer);
                    cmbCompany.SelectedIndex = 0;
                }
            }

        }
#endregion

    }
}
